{include file="common/head"/}
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
    </script>
    {include file="common/left"}
    <div class="main-content">
        <div class="main-content-inner">
            {include file="common/header_nav"}
            <div class="page-content">
                <div class="row maintop">
                    <div class="col-xs-12 col-sm-2">
                        <a href="{:url('adminAdd')}">
                            <button class="btn btn-xs btn-danger">
                                <i class="ace-icon fa fa-plus bigger-110"></i>
                                添加管理员
                            </button>
                        </a>
                    </div>
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('adminList')}">
                        <div class="col-xs-12 col-sm-6 btn-sespan">
                            <div class="input-group">
                                <span class="input-group-addon">
                                    <i class="ace-icon fa fa-search"></i>
                                </span>
                                <input type="text" name="val" id="val" class="form-control search-query admin_sea" value="{$testval}" placeholder="输入需查询的用户名"/>
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-xs btm-input btn-purple">

                                        搜索
                                    </button>
                                </span>
                            </div>
                        </div>
                        <div class="input-group-btn">
                            <a href="{:url('adminList')}">
                                <button type="button" class="btn btn-xs all-btn btn-purple">
                                    <span class="ace-icon fa fa-refresh icon-on-right bigger-110"></span>
                                    显示全部
                                </button>
                            </a>
                        </div>
                    </form>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <div class="col-xs-12">
                                <div class="table-responsive">
                                <table id="simple-table" class="table table-striped table-bordered table-hover center">
                                    <thead>
                                    <tr>
                                        <th class="center">登录用户名</th>
                                        <th class="center visible-lg visible-md">邮箱</th>
                                        <th class="center">用户组</th>
                                        <th class="center hidden-xs">电话号码</th>
                                        <th class="center visible-lg visible-md">登陆次数</th>
                                        <th class="center visible-lg visible-md">IP地址</th>
                                        <th class="center">状态</th>
                                        <th class="center" style="border-right:1px solid #ddd; ">操作</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    {volist name="admin_list" id="v"}
                                    <tr>
                                        <td>{$v.username}</td>
                                        <td class=" visible-lg visible-md">{$v.email}</td>
                                        <td>{$v.title}</td>
                                        <td class="hidden-xs">{$v.tel}</td>
                                        <td class="visible-lg visible-md">{$v.hits}</td>
                                        <td class="visible-lg visible-md">{$v.ip}</td>
                                        <td>
                                            {if condition='$v["is_open"] eq 1'}
                                            <a class="red" href="javascript:;" onclick="return stateyes({$v.admin_id});" title="已开启">
                                                <div id="zt{$v.admin_id}">
                                                    <button class="btn btn-minier btn-yellow">状态开启</button>
                                                </div>
                                            </a>
                                            {else/}
                                            <a class="red" href="javascript:;" onclick="return stateyes({$v.admin_id});" title="已禁用">
                                                <div id="zt{$v.admin_id}">
                                                    <button class="btn btn-minier btn-danger">状态禁用</button>
                                                </div>
                                            </a>
                                            {/if}
                                        </td>
                                        <td>
                                            <div class="action-buttons">
                                                <a class="green" href="{:url('adminEdit',['admin_id'=>$v['admin_id']])}" title="修改">
                                                    <i class="ace-icon fa fa-pencil bigger-130"></i> </a>
                                                <a class="red" href="javascript:;" onclick="return del({$v.admin_id});" title="删除">
                                                    <i class="ace-icon fa fa-trash-o bigger-130"></i> </a>
                                            </div>
                                        </td>
                                    </tr>
                                    {/volist}
                                    <tr>
                                        <td colspan="8" align="left">&nbsp;</td>
                                    </tr>
                                    </tbody>
                                </table>
                                </div>
                            </div><!-- /.span -->
                        </div><!-- /.row -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    {include file="common/foot" /}

</div><!-- /.main-container -->

<!-- inline scripts related to this page -->
<script type="text/javascript">
    function del(id) {
        if (id == 1) {
            layer.alert('超级管理员不可删除', {icon: 4});
            return false;
        }
        layer.confirm('你确定要删除吗？', {icon: 3}, function (index) {
            layer.close(index);
            window.location.href = "{:url('adminDel')}?admin_id="+id;
        });
    }
    function stateyes(id) {
        $.post('{:url("adminState")}',{'id': id},function (data) {
            if (data.status==1) {
                if (data.info == '状态禁止') {
                    var a = '<button class="btn btn-minier btn-danger">状态禁用</button>'
                    $('#zt' + id).html(a);
                    return false;
                } else {
                    var b = '<button class="btn btn-minier btn-yellow">状态开启</button>'
                    $('#zt' + id).html(b);
                    return false;
                }
            }else{
                layer.alert(data.info, {icon: 4});
                return false;
            }
        });
        return false;
    }
</script>
</body>
</html>
